// $codepro.audit.disable numericLiterals
/**
 * uses view package
 */
package javamonsters.view;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JLabel;

import java.awt.FontFormatException;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.SwingConstants;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.io.File;
import java.io.IOException;

/**
 * TitleScreenView sets up what the user will see when the game
 * boots up and the title screen is shown.
 * 
 * @author elahurd3
 * @version 1.0
 */
public class TitleScreenView extends JPanel implements View {
	
	/**
	 * JLabel for title
	 */
	private final JLabel titleLabel;
	
	/**
	 * JButton for new game
	 */
	private final JButton newButton;
	
	/**
	 * JButton for loading a game
	 */
	private final JButton loadButton;
	
	/**
	 * JButton for loading instructions
	 */
	private final JButton instrButton;
	
	/**
	 * JButton for exiting
	 */
	private final JButton exitButton;
	
	/**
	 * fonts
	 */
	private final Font titleFont, buttonFont;
	
	/**
	 * Constructor for view that sets up all the necessary components
	 * @throws IOException 
	 * @throws FontFormatException 
	 */
	public TitleScreenView() throws FontFormatException, IOException {
		super.setBackground(Color.BLACK);
		
		final File fontFile = new File("Fonts/space age.ttf");
		final Font font = Font.createFont(Font.TRUETYPE_FONT, fontFile);
		titleFont = font.deriveFont(38f);
		buttonFont = font.deriveFont(18f);
		
		super.setPreferredSize(new Dimension(700, 380));
		final GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{174, 351, 184, 0};
		gridBagLayout.rowHeights = new int[]{76, 60, 60, 60, 60, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{
				0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		super.setLayout(gridBagLayout);
		
		titleLabel = new JLabel("Space Traders");
		titleLabel.setFont(titleFont);
		final GridBagConstraints gbc_titleLabel = new GridBagConstraints();
		gbc_titleLabel.fill = GridBagConstraints.BOTH;
		gbc_titleLabel.insets = new Insets(0, 0, 5, 5);
		gbc_titleLabel.gridx = 1;
		gbc_titleLabel.gridy = 0;
		super.add(titleLabel, gbc_titleLabel);
		titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
		titleLabel.setForeground(Color.WHITE);
		titleLabel.setBackground(Color.WHITE);
		newButton = new JButton("New Game");
		
		newButton.setFont(buttonFont);
		newButton.setPreferredSize(new Dimension(300, 20));
		final GridBagConstraints gbc_newButton = new GridBagConstraints();
		gbc_newButton.fill = GridBagConstraints.BOTH;
		gbc_newButton.insets = new Insets(0, 0, 5, 5);
		gbc_newButton.gridx = 1;
		gbc_newButton.gridy = 1;
		super.add(newButton, gbc_newButton);
		
		loadButton = new JButton("Load Game");
		loadButton.setFont(buttonFont);
		loadButton.setPreferredSize(new Dimension(300, 20));
		final GridBagConstraints gbc_loadButton = new GridBagConstraints();
		gbc_loadButton.fill = GridBagConstraints.BOTH;
		gbc_loadButton.insets = new Insets(0, 0, 5, 5);
		gbc_loadButton.gridx = 1;
		gbc_loadButton.gridy = 2;
		super.add(loadButton, gbc_loadButton);
		
		instrButton = new JButton("Instructions");
		instrButton.setFont(buttonFont);
		instrButton.setPreferredSize(new Dimension(300, 20));
		final GridBagConstraints gbc_instrButton = new GridBagConstraints();
		gbc_instrButton.fill = GridBagConstraints.BOTH;
		gbc_instrButton.insets = new Insets(0, 0, 5, 5);
		gbc_instrButton.gridx = 1;
		gbc_instrButton.gridy = 3;
		super.add(instrButton, gbc_instrButton);
		
		exitButton = new JButton("Exit");
		exitButton.setFont(buttonFont);
		exitButton.setPreferredSize(new Dimension(300, 20));
		final GridBagConstraints gbc_exitButton = new GridBagConstraints();
		gbc_exitButton.insets = new Insets(0, 0, 0, 5);
		gbc_exitButton.fill = GridBagConstraints.BOTH;
		gbc_exitButton.gridx = 1;
		gbc_exitButton.gridy = 4;
		super.add(exitButton, gbc_exitButton);
		
		
	}
	
	/**
	 * Getter to return the new button
	 * @return a JButton representing the new button
	 */
	public JButton getNewButton() {
		return newButton;
	}
	
	/**
	 * Getter to return the load button
	 * 
	 * @return a JButton representing the load button
	 */
	public JButton getLoadButton() {
		return loadButton;
	}
	
	/**
	 * Getter to return the inserter button
	 * 
	 * @return a JButton representing the instructions button
	 */
	public JButton getInstrButton() {
		return instrButton;
	}
	
	/**
	 * Getter to return the exit button
	 * 
	 * @return a JButton representing the exit button
	 */
	public JButton getExitButton() {
		return exitButton;
	}
	
	/**
	 * Returns the titleLabel instance variable
	 * @return titleLabel instance variable
	 */
	public JLabel getTitleLabel() {
		return titleLabel;
	}
	
}
